"""
二分法搜索插入位置
"""
class Solution:
    def searchInsert(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: int
        """
        left, right = 0, len(nums)-1
        while left <= right:
            mid = (left + right)//2
            if nums[mid] == target:
                return min
            elif nums[mid] > target:
                left = mid + 1
            else:
                right = mid - 1
        return left
